package cn.yunhe.controller;

import cn.yunhe.service.IProvinceService;
import net.sf.json.JSONObject;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/after/DelProvinceServlet")
public class DelProvinceServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //删除目的地
        int indexId = Integer.parseInt(request.getParameter("indexId"));
        IProvinceService provinceService = new IProvinceService();

        response.setContentType("text/json;charset=UTF-8");
        PrintWriter out = response.getWriter();
        JSONObject jsonObject= new JSONObject();
        if (provinceService.delProvince(indexId)){
            jsonObject.put("flag",true);
            out.print(jsonObject);
        }else{
            jsonObject.put("flag",false);
        }

    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }
}
